package org.red_cross_service.service;

import org.red_cross_service.common.response.Response;
import org.red_cross_service.domain.entity.PlatformEntity;
import org.red_cross_service.mapper.PlatformMapper;
import org.red_cross_service.utils.QueryWrapperUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PlatformService {

    @Autowired
    PlatformMapper platformMapper;

    public Response getList(PlatformEntity platformEntity) {
        return Response.success(platformMapper.selectList(
                QueryWrapperUtils.buildQuery(platformEntity)
        ));
    }

    public Response add(PlatformEntity platformEntity) {
        return platformMapper.insert(platformEntity) > 0 ? Response.success() : Response.error();
    }
    public Response update(PlatformEntity platformEntity) {
        return platformMapper.updateById(platformEntity) > 0 ? Response.success() : Response.error();
    }
    public Response delete(Integer id) {
        return platformMapper.deleteById(id) > 0 ? Response.success() : Response.error();
    }
    public Response selectOne(PlatformEntity platformEntity) {
        return Response.success(platformMapper.selectOne(
                QueryWrapperUtils.buildQuery(platformEntity)
        ));
    }
}
